package org.ichow.scenegame.notis
{
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.display.Sprite;
	import flash.events.EventDispatcher;

	/**
	 * ...
	 * @author M.ichow
	 */
	public class BaseNoti extends EventDispatcher
	{
		protected var _container : DisplayObjectContainer;
		protected var _noti : DisplayObject;

		public function BaseNoti()
		{
		}

		protected function init() : void
		{
		}

		protected function addListeners() : void
		{
		}

		protected function removeListeners() : void
		{
		}

		public function active() : void
		{
			addListeners();
			_container.addChild( _noti );
		}

		public function cancel() : void
		{
			removeListeners();
			if (_container.contains( _noti ) )
				_container.removeChild( _noti );
		}

		public function reset() : void
		{
		}

		public function update( o : Object = null ) : void
		{
			for ( var i : Object in o )
			{
				if (this.hasOwnProperty( i ))
					this[i] = o[i];
				else if ( _noti.hasOwnProperty( i ) )
					_noti[ i ] = o[ i ];
			}
		}

		public function get noti() : DisplayObject
		{
			return _noti;
		}

		public function bind( noti : DisplayObject , container : DisplayObjectContainer ) : void
		{
			_container = container;
			_noti = noti;
			init();
		}

	}

}